#ifndef _HAL_IO_DAVID_H
#define _HAL_IO_DAVID_H



#ifndef CTL_CODE
#define CTL_CODE( DeviceType, Function, Method, Access ) (                 \
    ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
)
#endif

#define MEASURE_ISR_PERFORMANCE

#ifdef MEASURE_ISR_PERFORMANCE
typedef struct tagISR_PER_COUNT
{
	DWORD	dwMinTime;
	DWORD	dwMaxTime;
	DWORD	dwTotalTime;
	DWORD	dwCount;
	DWORD	dwMaxTimeID;
}ISR_PER_COUNT, *PISR_PER_COUNT;

#endif

#define OEM_HAL_IO_CODE_START			2048

#define IOCTL_HAL_GET_SYS_CLOCK_INFO			CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_HAL_SET_SYS_CLOCK_INFO			CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_HAL_INIT_DEEP_IDLE				CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_HAL_SET_DEEP_IDLE_WAKE_SOURCE		CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 3, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_HAL_RESET_DEEP_IDLE_WAKE_SOURCE	CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 4, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_HAL_ENTER_DEEP_IDLE				CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 5, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_HAL_INIT_ISR_MEASURE				CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_HAL_START_ISR_MEASURE				CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_HAL_STOP_ISR_MEASURE				CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_HAL_QUERY_ISR_MEASURE				CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 9, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_ENABLE_PLL2_FOR_USB				CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 10, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_DISABLE_PLL2						CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 11, METHOD_BUFFERED, FILE_ANY_ACCESS)


#define IOCTL_HAL_GET_POWER_STATE				CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 13, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_HAL_SET_POWER_STATE				CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 14, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_HAL_PM_GETIDLEMONTIME				CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 17, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_HAL_PM_SETIDLEMONTIME				CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 18, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_HAL_PM_REQUESTTURBO				CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 19, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_HAL_PM_RELEASETURBO				CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 20, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_HAL_PM_GETTURBOREQ				CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 21, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_HAL_INVALIDATE_DCACHE_LINES			CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 22, METHOD_BUFFERED, FILE_ANY_ACCESS)

// yanfeng for test
#define IOCTL_SWITCH_EXTERNAL_CLOCK					CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 23, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_SDHC_GET_WRITE_PROTECT_STATUS			CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 24, METHOD_BUFFERED, FILE_ANY_ACCESS)

// clock switch
#define IOCTL_HAL_CLOCK_SWITCH                  CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 25, METHOD_BUFFERED, FILE_ANY_ACCESS)

// zpzeng for max6900
#define IOCTL_SET_EXT_REAL_TIME					CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 26, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_GET_EXT_REAL_TIME					CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 27, METHOD_BUFFERED, FILE_ANY_ACCESS)

//david for map

#define IOCTL_HAL_GET_DEVICE_CODE				CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 26, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_HAL_GET_MAP_CODE					CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 27, METHOD_BUFFERED, FILE_ANY_ACCESS)			

// zhiguoxiong for test
#define IOCTL_SET_RTC_ALARM_TIME				CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 46, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_DISABLE_RTC_ALARM					CTL_CODE(FILE_DEVICE_HAL, OEM_HAL_IO_CODE_START + 47, METHOD_BUFFERED, FILE_ANY_ACCESS)

#endif

